var totleTable;
/****列表信息*/
function queryChexingTotal() {
	showLoading("查询中...");
	$.ajax( {
		url : 'chexingCity/queryChexingTotal.do',
		type : 'get',
		async:true,
		dataType : 'html',
		success : function(html) {
			$('#mainForm').html(html);
			queryChexingDatas();
			hideLoading();
		}
	});
}
function queryChexingDatas(){
		var province=$("#province").val();
	var colums = [ {
		columnName : '车型名称',
		name : 'name'
	}, {
		columnName : '创建时间',
		name : 'crateDate'
	}, {
		columnName : '更新时间',
		name : 'updateDate'
	}];
	if(province){
	colums = [ {
		columnName : '车型名称',
		name : 'name'
	}, {
		columnName : '创建时间',
		name : 'crateDate'
	}, {
		columnName : '更新时间',
		name : 'updateDate'
	}, {
		columnName : '城市',
		name : 'city',
		formatter : function(obj) {
			if (obj.city) {
				return obj.city;
			} else {
				return "";
			}
		}
	} ];
	}
	totleTable = $('#entTable').table( {
		width : '100%',
		defaultOrderBy : "id",
		defaultOrderType : "asc",
		form : {
			url : 'chexingCity/searchChexing.do?t='+(new Date()),
			id : '#entSearchForm',
			type : 'post',
			pageNumberText : '#pageNum'
		},
		pageable : true,
		selectable : true,
		colums : colums
	});
}
function queryChexingAllPage() {
	showLoading("查询中...");
	queryChexingDatas();
	hideLoading();
}

function queryBetteryTotal(){
	showLoading("查询中...");
	$.ajax({
		url : 'batteryPrice/queryBetteryTotal.do',
		type : 'get',
		async:true,
		dataType : 'html',
		success : function(html) {
			$('#mainForm').html(html);
			queryBetteryAllDatas();
			hideLoading();
		}
	});
}
function queryBetteryAllDatas(){
	var province=$("#province").val();
	var colums = [ {
			columnName : '电池品牌',
			name : 'pinPai',
			sortable : false
		}, {
			columnName : '电池型号',
			name : 'xingHao',
			sortable : false
		}, {
			columnName : '市场换够价',
			name : 'marketPrice',sortable : false
		}, {
			columnName : '本网换购价',
			name : 'ourPrice',
			sortable : false,sortable : false
		}
		, {
			columnName : '最后更新时间',
			name : 'updateDate'
		}];
	if(province){
	 colums = [ {
			columnName : '电池品牌',
			name : 'pinPai',
			sortable : false
		}, {
			columnName : '电池型号',
			name : 'xingHao',
			sortable : false
		}, {
			columnName : '市场换够价',
			name : 'marketPrice',sortable : false
		}, {
			columnName : '本网换购价',
			name : 'ourPrice',
			sortable : false,sortable : false
		}, {
			columnName : '省',
			name : 'province',
			sortable : false
		}, {
			columnName : '市',
			name : 'city',
			sortable : false
		}, {
			columnName : '县',
			name : 'town',
			sortable : false
		}
		, {
			columnName : '最后更新时间',
			name : 'updateDate'
		}];
	}
	totleTable= $('#entTable').table( {
		width : '100%',
		defaultOrderBy:"sort",
		defaultOrderType:"asc",
		form : {
			url : 'batteryPrice/queryBetteryAllPage.do',
			id : '#entSearchForm',
			type : 'post',
			pageNumberText : '#pageNum'
		},
		pageable : true,
		selectable : true,
		colums : colums
	});
}
function queryBetteryAllPage(){
	showLoading("查询中...");
	queryBetteryAllDatas();
	hideLoading();
}

function getShiX(obj,shiId,quId,chexing){
				if($(obj).val()==''){
					$("#"+shiId).empty();
					$("#"+shiId).html("<option value=''>选择市</option>");
					$("#"+quId).empty();
					$("#"+quId).html("<option value=''>选择区</option>");
					var html="";
					$.ajax({
					url:'chexingCity/queryByCity.do?t='+(new Date()),
					type:'post',
					dataType:'json',
					success:function(json){
						var shis = json;
						$("#"+chexing).empty();
						for(var i=0;i<shis.length;i++){
							html +="<option value='"+shis[i].id+"'>"+shis[i].name+"</option>";
						}
						$('#'+chexing).html(html);
					}
				});
					return;
				}
				$.ajax({
					url:'district/queryCityByProvince.do?t='+(new Date()),
					type:'post',
					data:{pname:$(obj).val()},
					dataType:'json',
					success:function(json){
						var shis = json;
						$("#"+quId).empty();
						$("#"+quId).html("<option value=''>选择区</option>");
						var html="";
						for(var i=0;i<shis.length;i++){
							html +="<option value='"+shis[i].name+"'>"+shis[i].name+"</option>";
						}
						$('#'+shiId).html(html);
						getQuChexing(document.getElementById(shiId),quId,chexing);
					}
				});
			}
			function getQuChexing(obj,quId,chexing){
				$.ajax({
					url:'district/queryTownByCity.do?t'+(new Date()),
					type:'post',
					data:{pname:$(obj).val()},
					dataType:'json',
					success:function(json){
						var qus = json;						
						var html="<option value=''>选择区</option>";
						$("#"+quId).empty();
						for(var i=0;i<qus.length;i++){
							html +="<option value='"+qus[i].name+"'>"+qus[i].name+"</option>";
						}
						$('#'+quId).html(html).parent().css('display','');
					}
				});
				$.ajax({
					url:'chexingCity/queryByCity.do?t='+(new Date()),
					type:'post',
					data:{city:$(obj).val()},
					dataType:'json',
					success:function(json){
						var shis = json;
						var html="";
						$("#"+chexing).empty();
						for(var i=0;i<shis.length;i++){
							html +="<option value='"+shis[i].id+"'>"+shis[i].name+"</option>";
						}
						$('#'+chexing).html(html);
					}
				});
			}